﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using Zcu.PanelComposer.Models.Model;
using System.ComponentModel.Composition;
using Zcu.PanelComposer.Interfaces;

namespace Zcu.PanelComposer.Models.Repository
{
    /// <summary>
    /// Pristup do lokalni databaze.
    /// </summary>
    [Export(typeof(IRepository))]
    public class DataRepository : BaseRepository
    {
        #region Properties

        /// <summary>
        /// Gets or sets the service.
        /// </summary>
        /// <value>
        /// The service.
        /// </value>
        public override DataContext Service { get; set; }

        #endregion // Properties

        #region Constructors

        /// <summary>
        /// Konstruktor s defaultnim connection stringem.
        /// </summary>
        public DataRepository()
            : this(Properties.Settings.Default.connectionDataString)
        { }

        /// <summary>
        /// Konstruktor, s novym connection stringem.
        /// </summary>
        /// <param name="conn"></param>
        private DataRepository(string conn)
        {
            if (Service == null)
            {
                Service = new ComposerData(conn);
            }
        }

        #endregion // Constructors
    }
}
